//
//  NSArray+NSLog.m
//  3.20解决汉字编码
//
//  Created by 廖易诚 on 16/3/20.
//  Copyright © 2016年 liaoyicheng. All rights reserved.
//

#import "NSArray+NSLog.h"

@implementation NSArray (NSLog)

- (NSString *)descriptionWithLocale:(id)locale {
    
    // 创建可变字符串
    NSMutableString *strM = [NSMutableString string];
    
    // 拼接左边括号
    [strM appendString:@"(\n"];
    
    // 遍历数组
    [self enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        // 将数组的所有元素做拼接操作
        [strM appendFormat:@"\t%@\n",obj];
    }];
    
    // 拼接右边括号
    [strM appendFormat:@")\n"];

    // 返回字符串
    return strM.copy;
}

@end


@implementation NSDictionary (NSLog)

- (NSString *)descriptionWithLocale:(id)locale {
    // 创建可变字符串
    NSMutableString *strM = [NSMutableString string];
    
    // 拼接左边括号
    [strM appendString:@"{\n"];
    
    [self enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        [strM appendFormat:@"\t%@:%@\n",key,obj];
    }];
    
    // 拼接右边括号
    [strM appendFormat:@"}\n"];
    
    // 返回字符串
    return strM.copy;
}

@end
